<template>
  <div class="view-wrapper">
    <div class="merchantsId">商家编号：{{ this.id }}</div>
    <div class="view-inner-wrap">
      <el-tabs v-model="activeName" @tab-click="tabClick">
        <el-tab-pane label="店铺功能模块" name="nine" :lazy="true">
          <div class="tabs-body">
            <MerchantsFunction ref="merchantsFunctionRef" :id="id" />
          </div>
        </el-tab-pane>
        <el-tab-pane label="证件信息" name="first" v-if="type == 1">
          <div class="tabs-body">
            <information ref="informationRef" :id="id" />
          </div>
        </el-tab-pane>
        <el-tab-pane label="店铺信息" name="second" :lazy="true">
          <div class="tabs-body">
            <store-detail :id="id" />
          </div>
        </el-tab-pane>
        <el-tab-pane label="资产信息" name="third" v-if="type == 1" :lazy="true">
          <div class="tabs-body">
            <assets-detail />
          </div>
        </el-tab-pane>
        <el-tab-pane label="钱包信息" name="fourth" v-if="type == 1" :lazy="true">
          <div class="tabs-body">
            <wallet-detail />
          </div>
        </el-tab-pane>
        <el-tab-pane label="会员信息" name="five" v-if="type == 1" :lazy="true">
          <div class="tabs-body">
            <member-detail />
          </div>
        </el-tab-pane>
        <el-tab-pane label="发卡规模&银行存管" name="six" v-if="type == 1" :lazy="true">
          <div class="tabs-body">
            <scale-deposit />
          </div>
        </el-tab-pane>
        <!-- <el-tab-pane label="抖音团购设置" name="seven" v-if="type == 1" :lazy="true">
          <div class="tabs-body">
            <dy-buying :id="id" />
          </div>
        </el-tab-pane> -->
        <el-tab-pane label="保险设置" name="eight" v-if="type == 1" :lazy="true">
          <div class="tabs-body">
            <insurance-settings ref="insuranceSettingsRef" />
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>
<script>
// components
import MerchantsFunction from "./components/merchantsDetail/merchantsFunction";
import Information from "./components/merchantsDetail/information";
import StoreDetail from "./components/merchantsDetail/storeDetail";
import AssetsDetail from "./components/merchantsDetail/assetsDetail";
import WalletDetail from "./components/merchantsDetail/walletDetail";
import MemberDetail from "./components/merchantsDetail/memberDetail";
import ScaleDeposit from "./components/merchantsDetail/scaleDeposit";
import dyBuying from "./components/merchantsDetail/dyBuying";
import insuranceSettings from "./components/merchantsDetail/insuranceSettings"; 
export default {
  name: "CreditDetail",
  components: {
    MerchantsFunction,
    Information,
    StoreDetail,
    AssetsDetail,
    WalletDetail,
    MemberDetail,
    ScaleDeposit,
    dyBuying,
    insuranceSettings,
  },
  provide() {
    const { id,cancelAudit } = this.$route.query;
    return {
      id: id,
      cancelAudit:cancelAudit, //判断查看入口路径 1 商户注销审核列表
    };
  },
  data() {
    return {
      activeName: "nine",
      id: "",
      assetId: "",
      type: "", //注册类型
    };
  },
  created() {
    const { id,shopManageId,type,cancelAudit } = this.$route.query;
    if(type==1){
      this.id = id;
    }else{
      this.id = shopManageId
    }
    
  },
  mounted() {
    let query = this.$route.query;
    console.log(query);
    this.type = query.type;
    if (query.activeName != undefined) {
      if (query.activeName) {
        this.activeName = query.activeName;
      } else {
        this.activeName = "first";
      }
    } else {
      if (this.type == 1) {
        this.activeName = "nine";
      } else {
        this.activeName = "second";
      }
    }
  },
  methods: {
    tabClick(e){
      console.log(e.index)
      if(e.index==0){
        this.$refs.merchantsFunctionRef.getDetail();
      }else if(e.index==1){
        this.$refs.informationRef.getApi();
      }else if(e.index==7){
        this.$nextTick(() => {
          this.$refs.insuranceSettingsRef.getApi();
			  })
       
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.merchantsId {
  color: #303133;
  font-size: 15px;
  margin-bottom: 16px;
}
</style>
